import { downloadFile, userAvatarDown, feedbackImgDown } from '../../api/file'

// export default async function downloadImg (fileId) {
//   const res = await downloadFile(fileId)
//   // // console.log(res)
// }

const downloadImg = async (fileIds) => {
  // const time = new Date(nowTime)
  // console.log(fileIds)
  const res = await downloadFile(fileIds)
  // console.log(res)
  return res
}

// 获取头像的url
const toBlobUrl = async (fileIds) => {
  // console.log(fileIds)
  const res = await downloadFile(fileIds)
  // console.log(res)
  const url = window.URL.createObjectURL(res.data)
  return url
}

// 获取用户管理头像的url
const toBlobUrlByUser = async (fileIds) => {
  // console.log(fileIds)
  const res = await userAvatarDown(fileIds)
  // console.log(res)
  const url = window.URL.createObjectURL(res.data)
  return url
}

// 获取意见反馈图片的url

const toBlobUrlByFeedback = async (fileIds) => {
  // console.log(fileIds)
  const res = await feedbackImgDown(fileIds)
  // console.log(res)
  const url = window.URL.createObjectURL(res.data)
  return url
}

export default {
  downloadImg,
  toBlobUrl,
  toBlobUrlByUser,
  toBlobUrlByFeedback
}
